package io;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class FileCopy {

	public static void main(String[] args) throws Exception {
		InputStream inputStream = new FileInputStream("a.jpg");
		OutputStream outputStream = new FileOutputStream("sb.jpg");
		long start = System.currentTimeMillis();
		int m = 0;
//		while ((m=inputStream.read())!=-1) {
//			outputStream.write(m);
//		}
		byte[] buf = new byte[1024];

		while ((m=inputStream.read(buf))!=-1) {
			outputStream.write(buf,0,m);
		}
		
		inputStream.close();
		outputStream.close();
		long end = System.currentTimeMillis();
		System.out.println(end-start+"ms");

	}
	
}
